<template>
	<view class="registered Dash">
		<view class="main">
			<view class="content">
				<view class="login-content">
					<view class="input-icon">
						<!-- <text class="cb">+86</text> -->
						<input class="login-pass" type="text" placeholder="请输入手机号码" v-model="mobile">
					</view>
					<view class="get-code">
						<input class="login-user" type="text" placeholder="请输入验证码" v-model="code">
						<view class="getcodebox">
							<get-code :verification='mobile' :type='types'></get-code>
						</view>
					</view>
					<view class="input-icon">
						<m-input class="m-input" type="password" displayable v-model="password" placeholder="请输入登录密码（6-12位数字或字母）"></m-input>
					</view>
					<view class="input-icon">
						<m-input class="m-input" type="password" displayable v-model="passwordC" placeholder="请再次输入你的密码"></m-input>
					</view>
				</view>
			</view>
		</view>
		<view class="reg-bottom">
			<button class="login-btn" @click="next">确认找回</button>
		</view>
	</view>
</template>

<script>
	import service from '../../service.js';
	import mInput from '../../components/m-input.vue';
	import getCode from '../../components/help/getCode.vue'
	export default {
		components: {
			mInput,
			getCode
		},
		data() {
			return {
				mobile: '', //手机号
				password: '', //登录密码
				code: '', //短信验证码
				verification: '',
				types: '',
				passwordC: ''
			}
		},
		methods: {

			//注册
			next() {
				if (this.mobile.length < 11) {
					uni.showToast({
						icon: 'none',
						title: '请输入正确手机号码'
					});
					return;
				}
				if (!this.code) {
					uni.showToast({
						icon: 'none',
						title: '请输入验证码'
					});
					return;
				}
				if (this.password.length < 6 || this.password.length > 12) {
					uni.showToast({
						icon: 'none',
						title: '登录密码不合法'
					});
					return;
				}
				if (this.password != this.passwordC) {
					uni.showToast({
						icon: 'none',
						title: '登录密码不一致'
					});
					return;
				}
				const data = {
					mobile: this.mobile, //手机号
					captcha: this.code, //验证码
					password: this.password, //登录密码
					confirmpwd: this.passwordC, //确认登录密码

				};
				const _this = this;
				this.$request.post("/api/user/resetpwd", {
						data: data,
					})
					.then(res => {
						uni.showToast({
							icon: 'none',
							title: res.data.msg
						});
						if (res.data.code == 1) {
							uni.reLaunch({
								url: '../login/login',
							});
						}
					})
					.catch(error => {
						console.error('error:', error);
					});
			}
		}
	}
</script>

<style lang="less">
	.registered {
		width: 100%;

		.hb-title {
			margin-bottom: 0;
		}

		.content {
			padding-top: 2vh;

			.login-content {
				padding: 0 30px;
				box-sizing: border-box;
			}
		}

		display: flex;
		flex-direction: column;

		.main {
			position: relative;
			width: 100%;
			border-radius: 0.133333rem;
			margin: 0 auto;
			flex-direction: column;



			.content {
				flex: 1;

				.login-content {
					flex: 1;
					width: 100%;
					margin-top: 20px;

					.input-icon {
						position: relative;
						height: 40px;
						line-height: 40px;
						font-size: 14px;
						box-sizing: content-box;
						background: #fff;
						text-align: left;
						border-bottom: 1px solid rgba(29, 123, 255, 1);

						margin: 0 auto 10px;

						.cb {
							color: rgba(29, 123, 255, 1);
						}

						.spanright {
							position: absolute;
							width: 1.066667rem;
							height: 0.666667rem;
							color: #A5A8B6;
							top: 0.4rem;
							right: 0;
							font-size: 0.533333rem !important;
							line-height: 0.3rem;
							text-align: center;
						}

						.phone-left {
							position: absolute;
							width: max-content;
							height: 40px;
							color: #999;
							top: 10px;
							left: 0;
							font-size: 14px;
							line-height: 40px;
							text-align: center;
						}

						input {
							width: 100%;
							height: 40px;
							padding: 0;
							outline: none;
							color: #333;
							border: none;
							font-size: 14px;
							background: rgba(255, 255, 255, 0);
							line-height: 70px;
							text-align: left;
						}

						input::-webkit-input-placeholder {
							color: #777;
						}

						.iconfont {
							font-size: 14px;
						}

						.login-invitation {
							display: block;
							width: 100%;
							height: 40px;
							text-indent: 60px;
							color: #FFDA8F;
							background-color: #393737;
							border-radius: 50px;
							line-height: 40px;
							font-size: 14px;

							span {
								float: right;
								margin-right: 40px;
							}
						}
					}

					.get-code {
						display: flex;
						align-items: center;
						height: 40px;
						position: relative;
						overflow: hidden;
						padding: 10px 0;
						background: #fff;
						font-size: 14px;
						margin: 0 auto 10px;
						border-bottom: 1px solid rgba(29, 123, 255, 1);
						box-sizing: content-box;

						input {
							width: 70%;
							height: 40px;
							outline: none;
							color: #333;
							border: none;
							float: left;
							text-align: left;
							font-size: 14px;
							background: rgba(255, 255, 255, 0);
						}

						input::-webkit-input-placeholder {
							color: #777;
						}

						.getcodebox {
							width: 30%;
							float: right;
							height: 30px;
							line-height: 30upx;
							font-size: 14px;

						}
					}

					.get-yzm {
						width: 100%;
						height: 40px;
						line-height: 40px;
						position: relative;
						overflow: hidden;
						border-bottom: 1px solid #EFEFEF;
						margin-bottom: 20px;

						input {
							width: 30%;
							height: 40px;
							outline: none;
							color: #333;
							border: none;
							float: left;
							background: rgba(255, 255, 255, 0);
						}

						input::-webkit-input-placeholder {
							color: #777;
						}

						.getcodebox {
							width: 40%;
							float: left;
							height: 100%;

							img {
								width: 100%;
							}
						}

						.info {
							width: 30%;
							float: left;
							height: 100%;
							color: #ED3D28;
						}
					}
				}

				/*.reg-bottom {*/
				/*height: 300px;*/
				/*}*/
			}

		}

		.login-btn {
			width: 50%;
			height: 38px;
			line-height: 38px;
			color: #fff;
			font-size: 0.533333rem;
			outline: none;
			border-radius: 0.133333rem;
			margin-top: 7%;
			border: none;
			background: #1d7bff;
			;
			font-size: 16px;
			position: absolute;
			bottom: 3rem;
			margin-left: 25%;
		}
	}






	.input-box {
		flex: 2;
		position: relative;
		display: flex;
		flex-direction: column;
		height: 100%;
		padding-top: 30px;

		.input-k {
			background: #fff;
			padding: 40px;
			width: 90%;
			margin: 0 auto;

			.input-icon {
				position: relative;
				overflow: hidden;
				margin: 60px 0;

				.incoleft {
					position: absolute;
					width: 80px;
					height: 50px;
					color: #0E286E;
					top: 15px;
					left: 0;
					font-size: 40px;
					line-height: 50px;
					text-align: center;
				}

				.incoright {
					position: absolute;
					width: 80px;
					height: 50px;
					color: #0E286E;
					top: 15px;
					right: 0;
					font-size: 40px;
					line-height: 50px;
					text-align: center;
				}

				input {
					width: 100%;
					height: 80px;
					outline: none;
					color: #10193B;
					background-color: #fff;
					border: none;
					text-align: left;
					text-indent: 1.2rem;
					font-size: 28px;
					border-bottom: 2px solid #0E286E;
				}

				input::-webkit-input-placeholder {
					color: #424d73;
				}
			}

		}

	}

	.login-bottom {
		width: 90%;
		margin: 0 auto;

		.login-btn {
			width: 99%;
			height: 90px;
			color: #fff;
			font-size: 40px;
			outline: none;
			border-radius: 10px;
			margin-top: 10%;
			border: none;
			background: linear-gradient(90deg, #58BEDE 0%, #306ACF 100%);
			box-shadow: 0px 1px 2px rgba(0, 0, 0, 0.41);
		}

		.bottom {
			margin: 50px auto;
			font-size: 28px;
			color: #306ACF;
			text-align: center;
		}
	}

	.mint-tab-container {
		height: 100%;
	}

	.m-input-view {
		padding: 0;
	}
</style>
